*************   Do-file for: Supplementary Appendix (Study 1)   ****************
*************   Date Modified: 09/09/2020  	                    ****************
*************   Created by: Adam D. Wolsky  	                ****************

clear
cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Analysis/Study1_Murphy/Data/"
use "study1_clean.dta"
set more off

/*   download user-written command cibar; type "ssc install outreg2" */
 
cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Analysis/Study1_Murphy/Logs/"

log using sa_study1_log, replace name("SA Study 1 Log File")

********************************    Table 1A    ********************************

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Tables"

outreg2 using descriptive_study1.doc, replace sum(log) ///
keep(female high_ed age hisp black asian partisan rep_other_dummy dem_other_dummy)

*****************************   Table 4A (Col 1)   *****************************

mlogit expcond female edu black hisp asian age news dem_other_dummy rep_other_dummy, b(1)
outreg2 using balance1.doc, replace addstat(LR chi2(16), e(chi2), p, e(p)) ctitle(Murphy) long

********************************    Table 5A    ********************************

reg reptherm i.t2vt1##ib7.pid7 if republican == 1
outreg2 using murphypidh1.doc, replace

********************************    Table 6A    ********************************

reg reptherm i.t3vt2##ib7.pid7 if republican == 1
outreg2 using murphypidh2.doc, replace

*******************************    Table 7A    *********************************

reg demtherm i.t2vt1##i.pid7 if democrat == 1
outreg2 using murphypidh3.doc, replace

*******************************    Figure 1A    ********************************

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Figures"

reg reptherm i.t2vt1##ib7.pid7 if republican == 1
margins, at(t2vt1=(0(1)1) pid7=(5(1)7)) level(90)
marginsplot, xtitle(" ") recast(bar) by(pid7) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(2.5) ///
xlabel(0 "Scandal" 1 "Hypocrisy")
graph export "fig1a.pdf", replace as(pdf) 

*******************************    Figure 2A    ********************************

reg reptherm i.t3vt2##i.pid7 if republican == 1
margins, at(t3vt2=(0(1)1) pid7=(5(1)7)) level(90)
marginsplot, xtitle(" ") recast(bar) by(pid7) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(2.5) ///
xlabel(0 "Hypocrisy" 1 "Resignation")
graph export "fig2a.pdf", replace as(pdf) 

*******************************    Figure 3A    ********************************

reg demtherm i.t2vt1##i.pid7 if democrat == 1
margins, at(t2vt1=(0(1)1) pid7=(1(1)3)) level(90)
marginsplot, xtitle(" ") recast(bar) by(pid7) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(2.5) ///
xlabel(0 "Scandal" 1 "Hypocrisy")
graph export "fig3a.pdf", replace as(pdf) 

*******************************    Table 11A    ********************************

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Tables"

reg reptherm i.t2vt1##i.vclosenews if republican == 1
outreg2 using murphynewsh1.doc, replace

*******************************    Table 12A    ********************************

reg reptherm i.t3vt2##i.vclosenews if republican == 1
outreg2 using murphynewsh2.doc, replace

*******************************    Table 13A    ********************************

reg demtherm i.t2vt1##i.vclosenews if democrat == 1
outreg2 using murphynewsh3.doc, replace

*******************************    Figure 7A   *********************************

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Figures"

reg reptherm i.t2vt1##i.vclosenews if republican == 1
margins, at(t2vt1=(0(1)1) vclosenews=(0(1)1)) level(90)
marginsplot, xtitle(" ") recast(bar) by(vclosenews) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(3) ///
xlabel(0 "Scandal" 1 "Hypocrisy")
graph export "fig10a.pdf", replace as(pdf) 

*******************************    Figure 8A   *********************************

reg reptherm i.t3vt2##i.vclosenews if republican == 1
margins, at(t3vt2=(0(1)1) vclosenews=(0(1)1)) level(90)
marginsplot, xtitle(" ") recast(bar) by(vclosenews) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(3) ///
xlabel(0 "Hypocrisy" 1 "Resignation")
graph export "fig11a.pdf", replace as(pdf) 

*******************************    Figure 12A   ********************************

reg demtherm i.t2vt1##i.vclosenews if democrat == 1
margins, at(t2vt1=(0(1)1) vclosenews=(0(1)1)) level(90)
marginsplot, xtitle(" ") recast(bar) by(vclosenews) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(3) ///
xlabel(0 "Scandal" 1 "Hypocrisy")
graph export "fig12a.pdf", replace as(pdf)

*******************************   Table 17A   **********************************

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Tables"

reg reptherm i.t2vt1##i.republican age edu female black hisp asian
outreg2 using murphyrobusth1.doc, replace

reg reptherm i.t2vt1##i.republican age edu female black hisp asian if pittsburgh_mm == 0
outreg2 using murphyrobusth1.doc, append

*******************************   Table 18A   **********************************

reg reptherm i.t3vt2##i.republican age edu female black hisp asian
outreg2 using murphyrobusth2.doc, replace

reg reptherm i.t3vt2##i.republican age edu female black hisp asian if pittsburgh_mm == 0
outreg2 using murphyrobusth2.doc, append

*******************************   Table 19A   **********************************

reg demtherm i.t2vt1##i.democrat age edu female black hisp asian
outreg2 using murphyrobusth3.doc, replace

reg demtherm i.t2vt1##i.democrat age edu female black hisp asian  if pittsburgh_mm == 0
outreg2 using murphyrobusth3.doc, append

* Data Audit * 

ttest reptherm if republican == 1 & duplicate_ip == 0, by(t2vt1)
ttest reptherm if republican == 1 & duplicate_ip == 0 & duplicate_latlong == 0, by(t2vt1)

ttest reptherm if republican == 1 & duplicate_ip == 0, by(t3vt2)
ttest reptherm if republican == 1 & duplicate_ip == 0 & duplicate_latlong == 0, by(t3vt2)

ttest demtherm if democrat == 1 & duplicate_ip == 0, by(t2vt1)
ttest demtherm if democrat == 1 & duplicate_ip == 0 & duplicate_latlong == 0, by(t2vt1)

log close _all
